<template>
	<div class="role" v-if="dialogFormVisible">
		<el-dialog :title="title" :visible="dialogFormVisible" :close-on-click-modal="false" width="800px" :before-close="handleClose">
			<div class="tab" v-if="activities">
				<el-timeline :reverse="true">
					<el-timeline-item
						v-for="(activity, index) in activities"
						:key="index"
						:timestamp="activity.timestamp">
						<span>操作人：{{activity.updated_by['name'] || '暂无'}}</span>
						<span style="margin: 0 15px;">操作：{{activity.type_show}}</span>
						<span>时间：{{getTime(activity.create_time)}}</span>

					</el-timeline-item>
				</el-timeline>
			</div>
			<div v-else>
				暂无记录
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button @click="handleClose">取 消</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
import {recode} from '@/api/user'

export default {
	name: 'addForm',
	data(){
		return {
			title:'操作记录',
			dialogFormVisible:false,
			activities: []
		}
	},
	created() {

	},
	methods:{
		getTime(data){
			var d = new Date(data);
			var d2 = d.getTime() - 8 * 60 * 60 * 1000
			d = new Date(d2)
			var  resDate = d.getFullYear() + '-' +
				((d.getMonth() + 1)<10?'0'+(d.getMonth() + 1):(d.getMonth() + 1)) + '-' +
				(d.getDate()<10?'0'+d.getDate():d.getDate())+ ' '+
				(d.getHours()<10?'0'+d.getHours():d.getHours())+':'+
				(d.getMinutes()<10?'0'+d.getMinutes():d.getMinutes())+':'+
				(d.getSeconds()<10?'0'+d.getSeconds():d.getSeconds());
			return resDate
		},
		handleClose(){
			this.dialogFormVisible = false
			this.form = {}
		},
		add(form){
			this.$refs[form].validate((valid) => {
				if (valid) {

				} else {
					return false;
				}
			});

		},
		initData(num,data){
			this.num = num
			this.id = data._id
			this.form = Object.assign({},data)
			recode(data._id).then(res => {
				this.activities = Object.assign({},res.data)
				console.log(res)
			})
		}
	}

}
</script>











